reflect-metadata is a polyfill for the Metadata Reflection API. When TypeScript compiles a class with emitDecoratorMetadata: true, it emits design:paramtypes metadata containing constructor parameter types. NestJS reads this at runtime with Reflect.getMetadata to know which tokens to resolve and inject.
NestJS depends on TypeScript's metadata emission to automatically detect what a class needs injected. Without reflect-metadata and the correct tsconfig options, NestJS cannot infer dependencies and will throw errors at startup.
TypeScript emits design:paramtypes metadata for every decorated class.
NestJS calls Reflect.getMetadata('design:paramtypes', MyService) to get an array of constructor parameter types.
Each type is used as a DI token to look up the registered provider in the module.
reflect-metadata must be imported once at the app entry point (main.ts) — NestJS does this automatically.